
from typing import List
class Solution:
    def dailyTemperatures(self, T: List[int]) -> List[int]:
        if not T:
            return []
        q = []
        res = len(T) * [0]
        for index in range(len(T)):
            print("q=", index, q, res)
            while q and T[q[-1]] < T[index]:

                res[q[-1]] = index - q[-1]
                q.pop()
            
            q.append(index)
        print(res)


temperatures = [73, 74, 75, 71, 69, 72, 76, 73]
# temperatures = [55,38,53,81,61,93,97,32,43,78]
Solution().dailyTemperatures(temperatures)